﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Shine.Framework;
using System.Runtime.InteropServices;

namespace Shine.File
{
    public partial class SceneList : UserControl, ICommand
    {
        IApplication m_Application = null;
        public SceneList()
        {
            InitializeComponent();
            comboBoxEx1.Items.Clear();
        }

        #region ICommand Members

        int ICommand.Bitmap
        {
            get { return 0; }
        }

        string ICommand.Caption
        {
            get { return "RouteList"; }
        }

        string ICommand.Category
        {
            get { return "飞行路线"; }
        }

        bool ICommand.Checked
        {
            get { return false; }
        }

        bool ICommand.Enabled
        {
            get
            {
                return true;
            }
        }

        int ICommand.HelpContextID
        {
            get { return 0; }
        }

        string ICommand.HelpFile
        {
            get { return string.Empty; }
        }

        string ICommand.Message
        {
            get { return "RouteList"; }
        }

        string ICommand.Name
        {
            get { return "RouteList"; }
        }

        void ICommand.OnClick()
        {
        }

        void ICommand.OnCreate(object hook)
        {
            m_Application = hook as IApplication;
            comboBoxEx1.Items.Clear();
            if( (m_Application as IFramework).WorkspaceControl==null) return;
           
            for (int i=0;i<   (m_Application as IFramework).WorkspaceControl.WorkspaceTree.Workspace.Scenes.Count;i++)
            {
                comboBoxEx1.Items.Add((m_Application as IFramework).WorkspaceControl.WorkspaceTree.Workspace.Scenes[i]);
            }
            
            comboBoxEx1.SelectedIndexChanged-= ComboBoxEx1_SelectedIndexChanged;
            if (comboBoxEx1.Items.Count > 0) comboBoxEx1.SelectedIndex = 0;
            comboBoxEx1.SelectedIndexChanged += ComboBoxEx1_SelectedIndexChanged;
             
        }

        private void ComboBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxEx1.SelectedItem == null) return;
            string str = comboBoxEx1.SelectedItem.ToString();
            (m_Application as IFramework).SceneControl.Scene.Open(comboBoxEx1.SelectedItem.ToString());
            (m_Application as IFramework).SceneControl.Scene.Refresh();
        }

        string ICommand.Tooltip
        {
            get { return "场景列表"; }
        }

        #endregion

        private void comboBoxEx1_KeyDown(object sender, KeyEventArgs e)
        {
            
        }

        private void comboBoxEx1_SelectedIndexChanged(object sender, EventArgs e)
        {
         // (m_Application as IFramework).SelectedRoute = comboBoxEx1.SelectedItem == null ? "" : comboBoxEx1.SelectedItem.ToString();
        }

        private void SceneList_Load(object sender, EventArgs e)
        {

        }
    }
}
